<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // Symbol
      var s = Symbol();
      var obj = {
        [s]: 'A',
      };
      var person = {
        name: '小明',
        age: 12,
        [Symbol['level']]: 'A',
      };

      // 并不具备迭代器的接口， Symbol.iterator
      for (var i in person) {
        console.log(i);
        // 打印不出 [Symbol['level']]
      }

      console.log(Object.keys(person)); // 打印出 ['name','age']  返回数组
      console.log(Object.getOwnPropertySymbols(person)); // 打印出 [Symbol['level']]

      // Relect.ownKeys可以打印出全部的keys
      console.log(Reflect.ownKeys(person));

      let s1 = Symbol.for('foo');
      let s2 = Symbol.for('foo');
      console.log(s1 === s2); //true
    </script>
  </body>
</html>
